package com.forezp.service;

import com.forezp.vo.Order;
import com.forezp.vo.TestParam;
import com.google.common.collect.Lists;
import com.mzt.logapi.starter.annotation.LogRecord;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.List;

@Service
public class TestService {


	@LogRecord(
			success = "{{#order.purchaseName}}下了一个订单,购买商品「{{#order.productName}}」,测试变量「{{#order.productName}}」,下单结果:{{#_ret}}",
			type = "销售单", bizNo = "{{#order.orderNo}}")
	public String test(Order order) {
		return "test";
	}

	public String test2(TestParam order) {
		try {
			System.out.println(1);
		} catch (Exception e) {

		}
		return "test";
	}



	public void testDiff1() {
		Order order = new Order();
		order.setOrderId(99L);
		order.setOrderNo("MT0000011");
		order.setProductName("超值优惠红烧肉套餐");
		order.setPurchaseName("张三");
		Order.UserDO userDO = new Order.UserDO();
		userDO.setUserId(9001L);
		userDO.setUserName("用户1");
		order.setCreator(userDO);
		order.setItems(Lists.newArrayList("123", "bbb"));


		Order order1 = new Order();
		order1.setOrderId(88L);
		order1.setOrderNo("MT0000099");
		order1.setProductName("麻辣烫套餐");
		order1.setPurchaseName("赵四");
		Order.UserDO userDO1 = new Order.UserDO();
		userDO1.setUserId(9002L);
		userDO1.setUserName("用户2");
		order1.setCreator(userDO1);
		order1.setItems(Lists.newArrayList("123", "aaa"));
//		orderService.diff(order, order1);
//
//		List<LogRecord> logRecordList = logRecordService.queryLog("xxx");
//		Assert.assertEquals(1, logRecordList.size());
//		LogRecord logRecord = logRecordList.get(0);
//		Assert.assertEquals(logRecord.getAction(), "更新了订单【创建人的用户ID】从【9001】修改为【9002】；【创建人的用户姓名】从【用户1】修改为【用户2】；【列表项】添加了【xxxx(aaa)】删除了【xxxx(bbb)】；【订单ID】从【xxxx(99)】修改为【xxxx(88)】；【订单号】从【MT0000011】修改为【MT0000099】；");
//		Assert.assertNotNull(logRecord.getExtra());
//		Assert.assertEquals(logRecord.getOperator(), "111");
//		Assert.assertEquals(logRecord.getBizNo(), order1.getOrderNo());
//		logRecordService.clean();
	}





}
